import { reqSearchGoodsInfo } from "@/api";

const searchStore = {
    namespaced: true,
    state: {
        goodsInfo:{}
    },
    getters:{
        attrsList(state){
            return state.goodsInfo.attrsList
        },
        goodsList(state){
            return state.goodsInfo.goodsList
        },
        trademarkList(state){
            return state.goodsInfo.trademarkList
        }
    },
    actions:{
        async getSearchGoodsInfo({commit},searchParams){
            const result = await reqSearchGoodsInfo(searchParams)
            if(result.data.code === 200){
                commit('UPDATE_SEARCH_GOODS_INFO',result)
                // console.log('result',result);
            }else{
                console.log('请求searchGoodsInfo数据失败');
            }
        }
    },
    mutations:{
        UPDATE_SEARCH_GOODS_INFO(state,payload){
            state.goodsInfo = payload.data.data
            console.log('payload.data.data',payload.data.data);
        }
    }
}

export default searchStore